package cn.getech.data.development.controller;

import cn.getech.data.development.model.req.search.SqlSearchLimitId;
import cn.getech.data.development.model.req.search.SqlSearchSaveReq;
import cn.getech.data.intelligence.common.utils.R;
import cn.getech.data.development.service.BdpSqlSearchLimitService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (BdpSqlSearchLimit)表控制层
 *
 * @author makejava
 * @since 2021-09-23 13:38:10
 */
@Api(tags = "数据开发sql限制")
@RestController
@RequestMapping("bdp/sqlSearchLimit")
public class BdpSqlSearchLimitController{
    /**
     * 服务对象
     */
    @Resource
    private BdpSqlSearchLimitService bdpSqlSearchLimitService;

    @ApiOperation("获取用户的角色列表")
    @GetMapping("/role/list")
    public R roleList() {
        return R.okWithData(bdpSqlSearchLimitService.roleList());
    }

    @ApiOperation("获取sql查询限制")
    @GetMapping("/sql/search/limit")
    public R sqlSearchLimit() {
        return R.okWithData(bdpSqlSearchLimitService.sqlSearchLimit());
    }

    @ApiOperation("删除配置")
    @PostMapping("/delete")
    public R delete(@RequestBody SqlSearchLimitId req) {
        return R.okWithData(bdpSqlSearchLimitService.removeById(req.getId()));
    }

    @ApiOperation("保存配置")
    @PostMapping("/save")
    public R save(@RequestBody SqlSearchSaveReq req) {
        bdpSqlSearchLimitService.saveLimit(req);
        return R.ok();
    }

    @ApiOperation("配置列表")
    @GetMapping("/list")
    public R list() {
        return R.okWithData(bdpSqlSearchLimitService.listDate());
    }

}
